I had the same problem. To be clear, the folders that were missing for me were Personal folders and all were for POP accounts.
I solved it by first creating a new personal Mailbox with a distinctive name "On My Mac".
With Mail quit, next I went into the ~/Library/Mail/V4 folder and looked into the folders that had various alphanumeric names until I found the new one with the distinctive name.
I then opened up my Time Machine disc from the Finder and drilled down to the last backup from El Capitan and went to the ~/Library/Mail/V3 folder and found my previously saved personal mailboxes, and dragged the smallest one to the folder in the V4 hierarchy with the newly created mailbox in it. I just used one mailbox to test whether the process worked.
Once it had copied across I went to the ~/Library/Mail/V4/Maildata folder and deleted any file with "Envelope" in it's name.
I then restarted Mail, and got a dialog that it was importing mail and once it completed, my personal mailbox had been re-created in the macOS Sierra Mail app.
Next I repeated the above steps with all the other remaining mailboxes from my old V3 mail and once they had all copied across, deleted the "Envelope" files again. This took quite a long time as there were quite a few years worth of mail to move over but it has worked perfectly since then (as far as I can tell).
Hope that helps.